<template>
	<view id="container">
		<view class="chatItem" v-for="(item, index) in chatHistory" :key="idnex" @click="toChatPage(chatHistory[index])">
			<view class="chatItemLeft">
				<view class="chatItemName">
					{{ item.name }}
				</view>
				<view class="chatItemPart">
					{{ item.chatContents[0].content }}
				</view>
			</view>
			<view class="chatItemDate">
				{{ item.chatContents[0].date }}
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState, mapMutations} from "vuex";
	export default {
		data() {
			return {
				
			};
		},
		mounted() {
		},
		computed:{
			...mapState('my_chatHistory', ['chatHistory'])
		},
		methods:{
			// 导入vuex中的方法
			...mapMutations('my_chatHistory',['getChatObj', 'addChatList']),
			// 跳转到聊天界面
			toChatPage(item){
				uni.navigateTo({
					url:"/pages/ChatD/ChatD?targetItem=" + JSON.stringify(item)
				})
			}
		}
	}
</script>

<style lang="scss">
	
	.container{
		display: flex;
		flex-direction: column;
	}
	
	.chatItemLeft{
		display: flex;
		flex-direction: column;
	}
	
	.chatItemName{
		font-size: 18px;
		font-weight: 600;
	}
	
	.chatItemPart{
		font-size: 13px;
		
	}
	
	.chatItemDate{
		padding-right: 15px;
	}
	
	.chatItem{
		height: 40px;
		width: 100vw;
		border: solid #6277ff 2px;
		padding: 5px;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}
	
</style>
